package com.xhlj.controller;

import com.xhlj.annotation.SystemLog;
import com.xhlj.service.CommentService;
import com.xhlj.utils.JwtHelper;
import com.xhlj.utils.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("comment")
public class CommentController {
    @Resource
    private CommentService commentService;
    @Resource
    private JwtHelper helper;

    /*
     * 获取对应帖子下的comment,按某种顺序排,应该不用我们排,前端自己排方便一点
     * */
    @GetMapping("list")
    public Result getCommentList(Integer postId) {
        Result res = commentService.getCommentList(postId);
        return res;
    }

    /*
     * 对comment进行点赞
     * */
    @SystemLog(title = "论坛模块",content = "论坛图片上传")
    @GetMapping("like")
    public Result likeComment(Integer commentId, @RequestHeader String Token) {
        Integer userId = helper.getPayLoad(Token).getUserId();
        Result res = commentService.likeComment(userId, commentId.toString());
        return res;
    }
    /*ws 会处理的*/
/*    public Result addComment(@RequestHeader String token, @RequestBody CommentBody comment) {
        Result res=commentService.addComment(comment);
        return res;
    }*/
}
